package com.example.makerspace.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.makerspace.domain.BmsLog;
import com.example.makerspace.mapper.BmsLogMapper;
import org.springframework.stereotype.Component;


import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Component
public class BmsLogServiceDAO extends BaseDAO<BmsLog>{
    @Resource
    private BmsLogMapper bmsLogMapper;

    @PostConstruct
    public void init(){
        this.mapper = bmsLogMapper;
    }

    public IPage<BmsLog> selectByPage(Page<BmsLog> page) {
        QueryWrapper<BmsLog> wq = new QueryWrapper<>();
        wq.orderByDesc("create_time");
        return  mapper.selectPage(page,wq);
    }

    public IPage<BmsLog> selectByPageAndType(Page<BmsLog> page, String type) {
        QueryWrapper<BmsLog> wq = new QueryWrapper<>();
        wq.eq("status",type).orderByDesc("create_time");
        return  mapper.selectPage(page,wq);
    }
}
